package common.item
{
	import com.common.utils.Reflection;
	import com.liangzhong.constants.TipsConst;
	import com.lz.football.module.base.IComponent;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import lz.controls.LItem;
	import lz.controls.managers.TipsManager;

	/**
	 *图标Icon 
	 * @author lake
	 * 
	 */	
	public class IconItem extends LItem implements IComponent
	{
		
		public function IconItem()
		{
			super();
		}
		
		override public function set data(value:*):void
		{
			super.data = value;
			var iconSkin :DisplayObject;
			var tempO :*;
			if(value is String)
			{
				tempO = Reflection.createInstance(value);
				if(tempO is DisplayObject)
				{
					iconSkin = tempO;
				}
				else if(tempO is BitmapData)
				{
					iconSkin = new Bitmap(tempO);
				}
				else
				{
					iconSkin = new Sprite();
				}
			}
			else if(value is BitmapData)
			{
				iconSkin = new Bitmap(value);
			}
			else if(value is DisplayObject)
			{
				iconSkin = value;
			}
			if(iconSkin)
			{
				this.addChild(iconSkin);
			}
		}
		
		override public function set tips(value:String):void
		{
			super.tips = value;
			this.addEventListener(MouseEvent.ROLL_OVER,onOverHandler);
			this.addEventListener(MouseEvent.ROLL_OUT,onOutHandler);
		}
		
		/**
		 * exp roll over
		 * show value
		 * @param e
		 * 
		 */		
		protected function onOverHandler(e :MouseEvent):void
		{
			TipsManager.show(TipsConst.BASETIPS,{tip:tips},15,15);
		}
		/**
		 * exp roll out
		 * hide
		 * @param e
		 * 
		 */		
		protected function onOutHandler(e :MouseEvent):void
		{
			TipsManager.hide();
		}
		/**
		 * 点击 
		 * @param e
		 * 
		 */		
		protected function onClickHandler(e :MouseEvent):void
		{
			
		}
		/**
		 * 选择
		 * 
		 */		
		override public function select():void
		{
			
		}
		/**
		 * 
		 * 去除选择
		 */		
		override public function unSelect():void
		{
			
		}
		/**
		 *初始化 
		 * @param view
		 * 
		 */		
		public function initUI(view:Object=null):void
		{
			
		}
		/**
		 *添加事件 
		 * 
		 */		
		public function addEvtListener():void
		{
			
		}
		/**
		 *删除事件 
		 * 
		 */		
		public function removeEvtListener():void
		{
			this.removeEventListener(MouseEvent.ROLL_OVER,onOverHandler);
			this.removeEventListener(MouseEvent.ROLL_OUT,onOutHandler);
		}
		/**
		 *销毁 
		 * 
		 */		
		public function destroyView():void
		{
			removeEvtListener();
		}
	}
}